package com.facemox.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.facemox.bean.FaceLink;
import com.facemox.bean.FaceLinkExecuteLog;

public interface LinkTestMapper {
    
    @Insert
    ("insert into face_link(link_id,link_name,link_node_sequence,link_node_name_sequence,link_detail) values(#{linkId},#{linkName},#{linkNodeSequence},#{linkNodeNameSequence},#{linkDetail})")
    @Options(keyColumn = "link_id",keyProperty = "linkId")
    int addLinkTest(FaceLink faceLink);
    
    @Select
    ("select * from face_link limit 0,25")
    @Results({
        @Result(column = "link_id",property = "linkId"),
        @Result(column = "link_name",property = "linkName"),
        @Result(column = "link_node_sequence",property = "linkNodeSequence"),
        @Result(column = "link_node_name_sequence",property = "linkNodeNameSequence"),
        @Result(column = "link_detail",property = "linkDetail")
    })
    List<FaceLink> getLinkList();
    
    @Select
    ("select * from face_link limit #{fromPage},#{toPage}")
    @Results({
        @Result(column = "link_id",property = "linkId"),
        @Result(column = "link_name",property = "linkName"),
        @Result(column = "link_node_sequence",property = "linkNodeSequence"),
        @Result(column = "link_node_name_sequence",property = "linkNodeNameSequence"),
        @Result(column = "link_detail",property = "linkDetail")
    })
    List<FaceLink> getLinkListPage(Integer fromPage,Integer toPage);
    
    @Select
    ("select count(*) from face_link")
    int getLinkListCount();
    
    @Select
    ("select * from face_link where link_id=#{linkId}")
    @Results({
        @Result(column = "link_id",property = "linkId"),
        @Result(column = "link_name",property = "linkName"),
        @Result(column = "link_node_sequence",property = "linkNodeSequence"),
        @Result(column = "link_node_name_sequence",property = "linkNodeNameSequence"),
        @Result(column = "link_detail",property = "linkDetail")
    })
    FaceLink findLinkById(Integer linkId);
    
    @Insert
    ("insert into face_link_execute_log(log_id,link_id,link_name,link_request_reponse_body,create_time) values(#{logId},#{linkId},#{linkName},#{linkRequestReponseBody},#{createTime})")
    @Options(keyColumn = "log_id",keyProperty = "logId")
    int addFaceLinkExecuteLog(FaceLinkExecuteLog faceLinkExecuteLog);
    
    @Delete
    ("delete from face_link where link_id=#{linkId}")
    int deleteLinkById(Integer linkId);
    
    @Update
    ("update face_link set link_name=#{linkName},link_node_sequence=#{linkNodeSequence},link_node_name_sequence=#{linkNodeNameSequence},link_detail=#{linkDetail} where link_id=#{linkId}")
    int updateLinkTest(FaceLink faceLink);
}
